<template>
	<view class="container">
		<mescroll-body ref="mescrollRef" @init="mescrollInit" @up="upCallback">
			<view class="category-list" v-if="currentTabIndex == 0">
				<navigator class="list b-f" hover-class="none" :url="'/pageShop/points/detail?goods_id=' + item.goods_id" v-for="(item, index) in goodslist" :key="index">
					<view class="left">
						<view class="img"><image class="goodsImg" mode="scaleToFill" :src="item.goods_image"></image></view>
					</view>
					<view class="right">
						<view class="cont">
							<!-- 商品名称 -->
							<text class="title f-29 twolist-hidden">{{ item.goods_name }}</text>
							<!-- 商品价格 -->
							<view class="detail-price onelist-hidden">
								<text class="goods-price f-30 col-m point">{{ item.goods_sku.goods_price }}</text>
							</view>
						</view>
					</view>
				</navigator>
			</view>
			<view class="goods-detail-box" v-if="currentTabIndex == 1">
				<view class="wrapper" wx:if="orderlist.length > 0">
					<view class="m-top20" v-for="(item, index) in orderlist" :key="index" @tap.stop="navigateToDetail" :data-id="item.order_id">
						<!-- <view class="order-box b-f">
							<view class="order-header dis-flex">
								<view class="flex-box t-l"><text class="title">商品列表</text></view>
								<view class="flex-box t-r">
									<text class="cont">{{ item.state_text }}</text>
								</view>
							</view>
						</view> -->
						<view class="order-box b-f">
							<view class="order-cont dis-flex">
								<view class="order-num">
									<text>订单号：{{ item.order_no }}</text>
								</view>
								<view class="order-time">
									<text>{{ item.create_time }}</text>
								</view>
							</view>
						</view>
						<view class="order-box order-img_list">
							<view class="order-shop">
								<view class="order-list-box dis-flex">
									<view class="left">
										<view class="dis-flex">
											<view class="order-shop-left" v-for="(good, gIndex) in item.goods" :key="gIndex"><image :src="good.image.file_path"></image></view>
										</view>
									</view>
									<view class="right dis-flex flex-x-center flex-y-center">
										<text class="goods-number">共{{ item.goods.length }}件</text>
										<text class="suifont sui-xiangyoujiantou user-orderJtou"></text>
									</view>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</mescroll-body>
		<u-tabbar v-model="currentTabIndex" :list="list" @change="changeTabIndex"></u-tabbar>
	</view>
</template>

<script>
import MescrollMixin from '@/components/mescroll-uni/mescroll-mixins.js';
export default {
	mixins: [MescrollMixin],
	data() {
		return {
			list: [
				{
					iconPath: 'home',
					selectedIconPath: 'home-fill',
					text: '商城',
					customIcon: false
				},
				{
					iconPath: 'account',
					selectedIconPath: 'account-fill',
					text: '订单',
					customIcon: false
				}
			],
			currentTabIndex: 0,
			goodslist: [],
			orderlist: []
		};
	},
	methods: {
		changeTabIndex(index) {
			setTimeout(() => {
				this.mescroll.resetUpScroll(true);
			}, 100);
		},
		upCallback(mescroll) {
			if (this.currentTabIndex == 0) {
				this.getPointsGoodsList(mescroll);
			} else {
				this.getPointsOrderList(mescroll);
			}
		},
		getPointsGoodsList(mescroll) {
			this.$u.api.getPointsGoodsList(mescroll.num).then(res => {
				const listData = res.data.list;
				if (mescroll.num == 1) {
					this.goodslist = listData.data;
				} else {
					this.goodslist.push(...listData.data);
				}
				this.mescroll.endBySize(listData.data.length, listData.total);
			});
		},
		getPointsOrderList(mescroll) {
			this.$u.api.getPointsOrderList(mescroll.num).then(res => {
				const listData = res.data.list;
				if (mescroll.num == 1) {
					this.orderlist = listData.data;
				} else {
					this.orderlist.push(...listData.data);
				}
				this.mescroll.endBySize(listData.data.length, listData.total);
			});
		},
		navigateToDetail(e) {
			let order_id = e.currentTarget.dataset.id;
			this.navigateTo({
				url: '/pageShop/points/order?order_id=' + order_id
			});
		}
	}
};
</script>

<style scoped lang="scss">
.container {
	overflow: hidden;
}
.store_nav_cont {
	padding: 20rpx 0;
}

.store_nav_cont #list-true {
	color: #ff495e;
	font-size: 28rpx;
}

.store_nav_cont #list-0 {
	color: #333;
	font-size: 28rpx;
}

.store_nav_cont .price__text {
	font-size: 28rpx;
}
.store_nav_cont .price__arrow {
	padding-left: 20rpx;
	font-size: 18rpx;
	color: #777;
}

.store_nav_cont #list-true .price__arrow text.active {
	color: #ff495e;
}

.container {
	position: relative;
}

.index-cont-search icon {
	left: 0;
	margin-left: 20rpx;
}

.index-search-box {
	background: #fff;
	padding: 18rpx 13rpx;
	border-bottom: 1rpx solid #eee;
}

.index-search {
	border-bottom: 0;
	background: #fff;
	border-radius: 50rpx;
	overflow: hidden;
	position: relative;
	font-size: 32rpx;
	color: #999;
	box-sizing: border-box;
	height: 64rpx;
	line-height: 64rpx;
	margin: 0 10rpx;
}

.list-right {
	width: 60rpx;
}

.list-right text {
	height: 60rpx;
	line-height: 60rpx;
	font-size: 40rpx;
}

.list-header {
	position: fixed;
	top: calc(--window-top + 1rpx);
	left: 0;
	right: 0;
}

.no-more {
	text-align: center;
	color: #737373;
	padding: 20rpx 0;
}

.category-list {
	overflow: hidden;
}

.category-list .list {
	box-sizing: border-box;
	width: 50%;
	float: left;
}

.category-list .list:nth-child(2n) {
	border-left: 4rpx solid #f7f7f7;
	border-bottom: 8rpx solid #f7f7f7;
}

.category-list .list:nth-child(2n-1) {
	border-right: 4rpx solid #f7f7f7;
	border-bottom: 8rpx solid #f7f7f7;
}

.category-list .list .left,
.category-list .right {
	width: 100%;
}

.category-list .list .left .img image {
	width: 100%;
	height: 375rpx;
	display: block;
}

.category-list .right .cont {
	padding: 10rpx 12rpx;
}

.category-list .right .cont .title {
	height: 76rpx;
	line-height: 1.3;
}

.category-list.arrange .list {
	overflow: hidden;
	padding: 15rpx;
	border-bottom: 1rpx solid #f7f7f7;
	width: 100%;
}

.category-list.arrange .list text {
	line-height: 1.6;
}

.category-list.arrange .list .left {
	width: 35%;
	float: left;
}

.category-list.arrange .list .right {
	width: 65%;
	float: left;
}

.category-list.arrange .list .left .img image {
	width: 220rpx;
	height: 220rpx;
}

/* 商品卖点 */

.selling_point {
	width: 100%;
	font-size: 24rpx;
	line-height: 1.4;
	color: #ff495e;
}

.goods_sales {
	color: #999;
	font-size: 24rpx;
}

/* 商品价格 */

.detail-price {
	font-size: 24rpx;
}
.point::before {
	content: '积分：';
	font-size: 20rpx;
}

.detail-price .goods-price {
	margin-right: 8rpx;
}

.detail-price .line-price {
	text-decoration: line-through;
}

//
.order-cont {
	/* padding: 12rpx 0; */
	justify-content: space-between;
}

.order-cont .order-num text,
.order-cont .time {
	color: #888;
}

.order-cont .order-num text,
.order-cont .order-time text {
	color: #777;
	font-size: 26rpx;
}

.checkout-right-detail,
.checkout-left-detail {
	font-size: 30rpx;
	color: #333;
	line-height: 92rpx;
}

.btn-default {
	border-radius: 4px;
	border: 1rpx solid #ccc;
	padding: 6rpx 20rpx;
	font-size: 28rpx;
	color: #555;
}

/* 会员价 */

.flow-shopList .flow-list-right .flow-cont.price-delete {
	font-size: 26rpx;
	color: #777;
	text-decoration: line-through;
}

.flow-shopList .grade-price {
	padding-top: 8rpx;
	font-size: 28rpx;
	color: #ff495e;
	text-align: right;
}

.order-box {
	padding: 0 15px;
}

.order-header {
	/* border-bottom: 1rpx solid #e4e4e4; */
	padding-top: 10rpx;
}

.order-header .title {
	font-size: 30rpx;
	color: #333;
}

.order-header .cont {
	/* display: block; */
	font-size: 30rpx;
	color: #fd4a5f;
}

.order-cont {
	padding: 15rpx 0;
	justify-content: space-between;
}

.order-cont .order-num text,
.order-cont .order-time text {
	color: #777;
	font-size: 26rpx;
}

.order-shop {
	padding: 16rpx 0 16rpx 0;
}

.order-shop-left,
.order-shop-left image {
	width: 160rpx;
	height: 160rpx;
	/* border: 1rpx solid #e4e4e4; */
	margin-right: 15rpx;
	display: inline-block;
	background: #fff;
}

.order-shop .num {
	float: right;
}

.order-btn {
	padding: 18rpx 0 18rpx 0;
}

.order-btn .order-left {
	flex: 3;
}

.order-btn .order-left text,
.order-btn .order-left .text {
	font-size: 29rpx;
}

.order-btn .order-left .text {
	color: #888;
}

.order-btn .order-right {
	flex: 3;
}

.order-btn .order-right .btn-group {
	justify-content: flex-end;
}

.order-list-box .left {
	flex: 4;
	overflow: hidden;
	position: relative;
}

.order-list-box .right {
	flex: 1;
}

.goods-number {
	font-size: 28rpx;
	color: #777;
}

.btn-default {
	border-radius: 4px;
	border: 1rpx solid #ccc;
	padding: 6rpx 20rpx;
	font-size: 28rpx;
	color: #555;
	float: right;
}

.btn-main {
	border-radius: 4px;
	border: 1rpx solid #fd4a5f;
	padding: 6rpx 20rpx;
	font-size: 28rpx;
	color: #fd4a5f;
	margin-left: 10rpx;
	float: right;
}

.user-orderJtou {
	font-size: 24rpx;
}

.order-img_list {
	background: #fff;
	border-top: 1rpx solid #f1f1f1;
	border-bottom: 1rpx solid #f1f1f1;
}

.order-right-name {
	position: absolute;
	top: 50%;
	left: 180rpx;
	font-size: 30rpx;
	color: #555;
	width: 100%;
	margin-top: -46rpx;
	line-height: 1.6;
}

/* 弹出层 */

.pop-example__container {
	background: #fff;
	padding: 30rpx 40rpx;
	border-radius: 10rpx;
	min-width: 460rpx;
}

.pop-example__container .pop-title {
	text-align: center;
}

.pop-content {
	margin-top: 30rpx;
}

/* 弹出层：核销码 */

.pop-qrcode .pop-content image {
	display: block;
	width: 460rpx;
	height: 460rpx;
}

/* 弹出层：支付方式 */

.pop-orderPay .pop-title {
	text-align: left;
}

.pay-method .pay-item {
	padding: 20rpx 0;
	font-size: 28rpx;
	/* border-bottom: 1rpx solid rgb(248, 248, 248); */
}

.pay-method .pay-item .item-left_icon {
	margin-right: 20rpx;
	font-size: 32rpx;
}

.pay-method .pay-item .item-left_icon.wechat {
	color: #00c800;
}

.pay-method .pay-item .item-left_icon.balance {
	color: #ff9700;
}
.pay-method .pay-item .item-left_icon.alipay {
	color: #0093e2;
}
</style>
